package com.example.duomeitijuhe.others;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.InputStream;

/**
 * Created by Michael on 2014/10/13.
 */
public class ReducePicture {
    Context context;

    public ReducePicture(Context context){
        this.context = context;

    }
    public Bitmap pictureToLess(int id,int size){
        //获取到id对应的Bitmap图片
        InputStream inputStream = context.getResources().openRawResource(id);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = false;
        options.inSampleSize = 1;
        Bitmap myBitmap = BitmapFactory.decodeStream(inputStream,null,options);
        float height = myBitmap.getHeight();

       //进行缩放
        int be = (int)height / size;
        BitmapFactory.Options options1 = new BitmapFactory.Options();
        options1.inJustDecodeBounds = false;
        options1.inSampleSize = be;
        Bitmap myBitmap2 = BitmapFactory.decodeStream(inputStream,null,options1);
        return myBitmap2;
    }


}
